import type {
  KnowledgePage,
  KnowledgeParams,
  DoctorPage,
  PageParams,
  FollowType,
  TopDep,
  Image,
} from '@/types/consult'
import { request } from '@/utils/request'

export const getKnowledgePage = (params: KnowledgeParams) =>
  request<KnowledgePage>({
    url: '/patient/home/knowledge',
    method: 'GET',
    data: params,
  })

export const getDoctorPage = (params: PageParams) =>
  request<DoctorPage>({ url: '/home/page/doc', method: 'GET', data: params })

export const followOrUnfollow = (id: string, type: FollowType = 'doc') =>
  request({ url: '/like', method: 'POST', data: { id, type } })

export const getAllDep = () => request<TopDep[]>({ url: '/dep/all' })

export const uploadImage = (file: File) => {
  const fd = new FormData()
  fd.append('file', file)
  return request<Image>({ url: '/upload', method: 'POST', data: fd })
}
